home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
ACORNUSERS
/
CBSA
/
EDUCATION
/
SAVER
/
cc
/
WimpIcon
< prev
next >
Wrap
Text File
|
1997-12-26
|
2KB
|
117 lines
//-----------------------------------
// WimpIcon.c
//-----------------------------------
#include <stdlib.h>
#include <string.h>
#include <os.h>
#include <trap.h>
#include "WimpError.h"
#include "EventData.h"
#include "WimpIcon.h"
WimpIcon::WimpIcon(WimpIcon &icon, int iflags, int window,
int priority, int x0, int y0, int x1, int y1)
{
int r[10];
os_error *e;
indirect = icon.indirect;
flags = iflags;
handle = window; // Provisoire
xmin = x0;
ymin = y0;
xmax = x1;
ymax = y1;
r[0] = priority;
r[1] = (int)&handle;
if ((e = os_swi(Wimp_CreateIcon, r)) != NULL) throw(e);
handle = r[0];
window_handle = window;
}
WimpIcon::WimpIcon(char *spritename, int iflags, int window, int priority,
int x0, int y0, int x1, int y1)
{
int r[10];
os_error *e;
if (iflags & INDIRECT)
{
indirect_sprite.sprite_name = new char[strlen(spritename)+1];
strcpy(indirect_sprite.sprite_name, spritename);
indirect_sprite.sprite_area = (int *)1;
indirect_sprite.isname = 1;
}
else strncpy(sprite_name, spritename, 12);
flags = iflags;
window_handle = window;
handle = window; // Provisoire
xmin = x0;
ymin = y0;
xmax = x1;
ymax = y1;
r[0] = priority;
r[1] = (int) &handle;
if ((e = os_swi(Wimp_CreateIcon, r)) != NULL) throw(e);
handle = r[0];
}
void WimpIcon::Delete()
{
int r[10];
os_error *e;
int b[2];
b[0] = window_handle;
if (b[0] < -1) b[0] = -2;
b[1] = handle;
r[1] = (int) b;
if ((e = os_swi(Wimp_DeleteIcon, r)) != NULL) throw(e);
}
WimpIcon::~WimpIcon()
{
if (flags & INDIRECT) delete indirect_sprite.sprite_name;
}
WimpIcon::operator int()
{
return handle;
}
void WimpIcon::GetState()
{
os_error *e;
int r[10];
r[1] = (int) this;
e = os_swi(Wimp_GetIconState,r);
}
void WimpIcon::drag()
{
os_error *e;
int r[10];
int ox,oy;
static Window_Info w;
static int DragData[14];
w.handle = window_handle;
r[1] = (int) &w;
e = os_swi(Wimp_GetWindowState,r);
ox = w.xmin - w.scrollx;
oy = w.ymax - w.scrolly;
GetState();
DragData[0] = window_handle;
DragData[1] = 5;
DragData[2] = ox + xmin;
DragData[3] = oy + ymin;
DragData[4] = ox + xmax;
DragData[5] = oy + ymax;
DragData[6] = 0;
DragData[7] = 0;
DragData[8] = 0x7FFFFFFF;
DragData[9] = 0x7FFFFFFF;
r[1] = (int) DragData;
e = os_swi(Wimp_DragBox,r);
}